﻿//using Kingdee.BOS;
//using Kingdee.BOS.App.Data;
//using Kingdee.BOS.Core.DynamicForm.PlugIn;
//using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
//using Kingdee.BOS.Orm.DataEntity;
//using Kingdee.BOS.Util;
//using Kingdee.BOS.WebApi.Client;
//using Newtonsoft.Json;
//using Newtonsoft.Json.Linq;
//using System;
//using System.Collections.Generic;
//using System.ComponentModel;
//using System.Data;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace WSDZ.KM.ZH.XiaoManIntegrating40
//{
//    /// <summary>
//    /// 小满
//    /// </summary>
//    [Description("更新erp客户"), HotUpdate]
//    public class CustomerManager 
//    {
//        public string btype = "更新erp客户";
//        /// <summary>
//        /// 日志文件路径
//        /// </summary>
//        public string logType = "更新erp客户";
//        public string formId = "BD_Customer";
//        public TokenData TokenObj = null;

//        public string XMUrl1 = "https://api-sandbox.xiaoman.cn/v1/company/updates";
//        public string XMUrl2 = "https://api-sandbox.xiaoman.cn/v1/company/info";

//        public Context ctx;
//        public string date1;
//        public string date2;

//        public int PageSize = 1000;
//        public int AllPage = 1;
   
//        Dictionary<string, string> headers;

//        public void Main(Context c,string d1,string d2)
//        {
//            try
//            {
//                ctx = c;
//                date1 = d1;
//                date2 = d2;
//                var tokens = PostHelper.GetToken(logType);
//                if (!tokens.Item1)
//                {
//                    LogHelper.XiaoManLog($"【获取token错误】【msg:{tokens.Item2.msg}】",logType);
//                    return;
//                }
//                TokenObj = tokens.Item2;
//                DealMethod();
//            }
//            catch (Exception ex)
//            {
//                LogHelper.XiaoManLog($"【异常A1001】【msg:{ex.Message}】", logType);
//            }
        
//        }
   
//        public void DealMethod()
//        {
           
//            headers = new Dictionary<string, string>();
//            headers.Add("Authorization", $@"Bearer {TokenObj.token}");
//            List<CustUpdateData> CUList = new List<CustUpdateData>();

//            for (int i = 1; i <= AllPage; i++)
//            {
//                try
//                {
//                    Dictionary<string, string> paraDics = new Dictionary<string, string>();
//                    paraDics.Add("start_time", date1);
//                    paraDics.Add("end_time", date2);
//                    paraDics.Add("start_index", i.ToStringV1());
//                    paraDics.Add("count", PageSize.ToStringV1());
//                    string dataContent = PostHelper.DicToParameter(paraDics);
//                    string resultStr = PostHelper.Get(XMUrl1, dataContent, headers);
//                    LogHelper.XiaoManLog($"【获取更新客户列表】\nheaders:{JsonConvert.SerializeObject(headers)}\n返回:{resultStr}", logType);
//                    JObject reObj = JsonConvert.DeserializeObject<JObject>(resultStr);
//                    if (reObj["code"].ToStringV1().EqualsV1("200") && reObj["message"].ToStringV1().EqualsV1("success"))
//                    {
               
//                        JObject dataObj = JsonConvert.DeserializeObject<JObject>(reObj["data"].ToStringV1());

//                        int totalItem = dataObj["totalItem"].ToStringV1().ToInt32V1();
//                        AllPage = totalItem <= PageSize ? 1 : totalItem % PageSize > 0 ? totalItem / PageSize + 1 : totalItem / PageSize;

//                        JArray dataArray = JsonConvert.DeserializeObject<JArray>(dataObj["list"].ToStringV1());
//                        if (dataArray!=null&&dataArray.Count>0)
//                        {
//                            List<CustUpdateData> clist = dataArray.Select(x => new CustUpdateData
//                            {
 
//                                Id=x["company_id"].ToStringV1(),
//                                Name=x["name"].ToStringV1(),
//                                ShortName = x["short_name"].ToStringV1(),
//                                SerId = x["serial_id"].ToStringV1(),
//                                ModifyDate = x["order_time"].ToStringV1().ToDateTime(),
//                                CreateDate = x["create_time"].ToStringV1(),
//                            }).ToList();
//                            CUList.AddRange(clist);
//                        }
//                    }
//                }
//                catch (Exception ex)
//                {
//                    LogHelper.XiaoManLog($"【获取更新客户列表】【异常C2001】\n【msg:{ex.Message}】", logType);
//                    continue;
//                }
           
//            }
//            if (CUList.Count>0)
//            {
//                CUList = CUList.GroupBy(x => x.Id).Select(x => x.FirstOrDefault()).ToList();
//                DealMethodV1(CUList);
//            }

//        }
//        List<Cust> custList = new List<Cust>();
//        List<Saler> salerList = new List<Saler>();
//        List<AuxiliaryInfo> auxiliaryList = new List<AuxiliaryInfo>();
//        List<AuxiliaryInfo> MJList = new List<AuxiliaryInfo>();
//        List<AuxiliaryInfo> custGroupList = new List<AuxiliaryInfo>();
//        List<AuxiliaryInfo> custSourceList = new List<AuxiliaryInfo>();

//        public void DealMethodV1(List<CustUpdateData> CUList)
//        {
//            string loginMsg = string.Empty;
//            if (!K3HelperV1.Login(ctx, ref loginMsg))
//                if (!K3HelperV1.Login(ctx, ref loginMsg))
//                {
//                    LogHelper.XiaoManLog($"【A1001】【登录失败】\n【msg:{loginMsg}】", logType);
//                    return;
//                }

//            //查询erp客户信息
//            {
//                string sql = $@"/*dialect*/ select 
//Id=cust.FCUSTID
//,xmId=cust.F_RLKX_xmcustid1
//,salerName=salerL.FNAME
//from T_BD_CUSTOMER cust
//left join V_BD_SALESMAN saler on cust.FSELLER=saler.fid
//left join V_BD_SALESMAN_L salerL on saler.fid=salerL.fid and salerL.FLOCALEID=2052";
//                DynamicObjectCollection cdatas = DBUtils.ExecuteDynamicObject(ctx, sql);
//                if (cdatas != null && cdatas.Count > 0)
//                    custList = cdatas.DynamicObjectCollectionToDataList<Cust>();
//            }
//            //客户分组
//            {
//                string sql = $@"select 
//Id=main.FID
//,Numebr=FNUMBER
//,Name=mainL.FNAME
//from T_BD_CUSTOMERGROUP main
//left join T_BD_CUSTOMERGROUP_L mainL on main.FID=mainL.FID and mainL.FLOCALEID=2052";
//                DynamicObjectCollection cdatas = DBUtils.ExecuteDynamicObject(ctx, sql);
//                if (cdatas != null && cdatas.Count > 0)
//                    custGroupList = cdatas.DynamicObjectCollectionToDataList<AuxiliaryInfo>();
//            }
//            //客户来源
//            {
//                string sql = $@"select 
//Id=main.FID
//,Numebr=FNUMBER
//,Name=mainL.FNAME
//from T_BAS_PREBDONE main
//left join T_BAS_PREBDONE_L mainL on main.FID=mainL.FID and mainL.FLOCALEID=2052";
//                DynamicObjectCollection cdatas = DBUtils.ExecuteDynamicObject(ctx, sql);
//                if (cdatas != null && cdatas.Count > 0)
//                    custSourceList = cdatas.DynamicObjectCollectionToDataList<AuxiliaryInfo>();
//            }

//            //销售员信息
//            {
//                string sql = $@"/*dialect*/ select 
//Id=saler.fid
//,Number=saler.FNUMBER
//,Name=salerL.FNAME
//,dptNumebr=dpt.FNUMBER
//from V_BD_SALESMAN saler
//left join V_BD_SALESMAN_L salerL on saler.fid=salerL.fid and salerL.FLOCALEID=2052
//left join T_BD_DEPARTMENT dpt on saler.FDEPTID=dpt.FDEPTID
//where saler.FDOCUMENTSTATUS='C'";
//                DynamicObjectCollection cdatas = DBUtils.ExecuteDynamicObject(ctx, sql);
//                if (cdatas != null && cdatas.Count > 0)
//                    salerList = cdatas.DynamicObjectCollectionToDataList<Saler>();
//            }
//            //查询辅助资料
//            {
//                string sql = $@"select 
//TypeNumber=lb.FNUMBER
//,TypeName=lbL.FNAME
//,Number= enty.FNUMBER
//,Name= entyL.FDATAVALUE
//from T_BAS_ASSISTANTDATAENTRY enty
//left join T_BAS_ASSISTANTDATAENTRY_L entyL on enty.FENTRYID=entyL.FENTRYID and entyL.FLOCALEID=2052
//left join T_BAS_ASSISTANTDATA lb on enty.FID=lb.FID
//left join T_BAS_ASSISTANTDATA_L lbL on lb.FID=lbL.FID and lbL.FLOCALEID=2052";
//                DynamicObjectCollection cdatas = DBUtils.ExecuteDynamicObject(ctx, sql);
//                if (cdatas != null && cdatas.Count > 0)
//                    auxiliaryList = cdatas.DynamicObjectCollectionToDataList<AuxiliaryInfo>();
//            }
//            //枚举值
//            {
//                string sql = $@"select 
//TypeNumber=mjType.FID
//,TypeName=mjTypeL.FNAME  --枚举类型名称
//,Number= mj.FVALUE  --枚举值
//,Name= mjL.FCAPTION  --枚举值名称
//from T_META_FORMENUM mjType
//inner join T_META_FORMENUM_L mjTypeL on mjType.FID =mjTypeL.FID and mjTypeL.FLOCALEID = 2052 
//inner join T_META_FORMENUMITEM mj on mj.FID = mjType.FID
//inner join T_META_FORMENUMITEM_L mjL ON mj.FENUMID = mjL.FENUMID and mjL.FLOCALEID = 2052
//where mj.FINVALID=0";
//                DynamicObjectCollection cdatas = DBUtils.ExecuteDynamicObject(ctx, sql);
//                if (cdatas != null && cdatas.Count > 0)
//                    MJList = cdatas.DynamicObjectCollectionToDataList<AuxiliaryInfo>();
//            }

      
//            foreach (CustUpdateData uObj in CUList)
//            {
//                try
//                {
//                    //查询客户详细信息
//                    Dictionary<string, string> paraDics = new Dictionary<string, string>();
//                    paraDics.Add("company_id", uObj.Id);
//                    string dataContent = PostHelper.DicToParameter(paraDics);
//                    //string resultStr = PostHelper.Get(XMUrl2, dataContent, headers);
//                    string xmUrl = XMUrl2 + "?" + dataContent;
//                    string resultStr = PostHelper.Get(xmUrl, "", headers);
//                    LogHelper.XiaoManLog($"【客户详细信息】\nheaders:{JsonConvert.SerializeObject(headers)}\n返回:{resultStr}", logType);
//                    JObject reObj = JsonConvert.DeserializeObject<JObject>(resultStr);
//                    if (reObj["code"].ToStringV1().EqualsV1("200") && reObj["message"].ToStringV1().EqualsV1("success"))
//                    {
//                        JObject dataObj = JsonConvert.DeserializeObject<JObject>(reObj["data"].ToStringV1());
//                        var erpCustObj = custList.Where(x => x.xmId.EqualsV1(uObj.Id)).FirstOrDefault();
//                        //erp已存在 则更新销售员即可  若不存在 则在erp新增一个 客户
//                        JArray companyArray = JsonConvert.DeserializeObject<JArray>(dataObj["company"].ToStringV1());
//                        if (erpCustObj!=null)
//                        {
//                            //获取业务员
//                            string ywy = "28514799207966".GetValueByKey(companyArray,"5");
//                            int salerId = salerList.Where(x => x.Name.EqualsV1(ywy)).Select(x=>x.Id).FirstOrDefault();
//                            string sql_u = $@"update T_BD_CUSTOMER set FSELLER={salerId} where FCUSTID={erpCustObj.Id}";
//                            DBUtils.Execute(ctx,sql_u);
//                        }
//                        //新增客户
//                        else
//                        {
//                            string json = FillContent(dataObj,uObj);
//                            string msg = string.Empty;
//                            JObject returnData = new JObject();
//                            bool isok = K3HelperV1.SaveV1(ctx,formId,json,ref msg,ref returnData);
//                            if (!isok)
//                                isok = K3HelperV1.DraftV1(ctx, formId, json, ref msg, ref returnData);
//                            if (isok)
//                            {
//                                LogHelper.XiaoManLog($"【客户保存成功】【{uObj.Name}】\n【json:{json}】", logType);
//                                var suStr = returnData["Result"]["ResponseStatus"]["SuccessEntitys"].ToStringV1();
//                                JArray array = JsonConvert.DeserializeObject<JArray>(suStr);
//                                int custId = array.Select(x => x["Id"].ToStringV1().ToInt32V1()).FirstOrDefault();
//                                string custNo = array.Select(x => x["Number"].ToStringV1()).FirstOrDefault();
//                                //创建联系人
//                                {
//                                    //string lxrStr = "customers".GetValueByKey(companyArray, "5");
//                                    string lxrStr = dataObj["customers"].ToStringV1();
//                                    JArray lxrArray = JsonConvert.DeserializeObject<JArray>(lxrStr);
//                                    if (lxrArray!=null&& lxrArray.Count>0)
//                                    {
//                                        var lxrList = lxrArray.Select(x =>
//                                        {
//                                            string gender = x["gender"].ToStringV1().EqualsV1("1")? "SEX01_SYS": "SEX02_SYS";
//                                            string name = x["name"].ToStringV1();
//                                            string email = x["email"].ToStringV1();
//                                            string post = x["post"].ToStringV1();
//                                            string tel = string.Empty;
//                                            JArray telArray = JsonConvert.DeserializeObject<JArray>(x["tel_list"].ToStringV1());
//                                            if (telArray!=null&& telArray.Count>0)
//                                                tel = telArray.FirstOrDefault().ToStringV1();
//                                            string address= "address".GetValueByKey(companyArray, "4");
//                                            return new 
//                                            {
//                                                gender= gender,
//                                                name = name,
//                                                email = email,
//                                                post = post,
//                                                tel = tel,
//                                                address = address,
//                                            };
//                                        }).ToList();
//                                        if (lxrList.Count>0)
//                                        {
//                                            JObject Root = new JObject();
//                                            JArray ModelArray = new JArray();
//                                            foreach (var lxr in lxrList)
//                                            {
//                                                JObject Model = new JObject();
//                                                Model["FCONTACTID"] = 0;
//                                                Model["FName"] = lxr.name;
//                                                Model["FCompanyType"] = "BD_Customer";

//                                                JObject FCompany = new JObject();
//                                                FCompany["FNumber"] = custNo;
//                                                Model["FCompany"] = FCompany;

//                                                JObject Fex = new JObject();
//                                                Fex["FNumber"] = lxr.gender;
//                                                Model["Fex"] = Fex;

//                                                Model["FPost"] = lxr.post;
//                                                Model["FMobile"] = lxr.tel;
//                                                Model["FBizLocNumber"] = lxr.tel;
//                                                Model["FBizLocation"] = lxr.address;
//                                                Model["FEmail"] = lxr.email;

//                                                ModelArray.Add(Model);
//                                            }
//                                            Root["Model"] = ModelArray;
//                                            json = Root.ToStringV1();
//                                            msg = string.Empty;
//                                            returnData = new JObject();
//                                            isok = K3HelperV1.BatchSave(ctx, "BD_CommonContact",json,ref msg,ref returnData);
//                                            LogHelper.XiaoManLog($"【联系人保存结果：{isok.ToStringV1()}】【客户名称：{uObj.Name}】\n【返回结果:{returnData.ToStringV1()}】\n【json:{json}】", logType);
//                                            if (isok)
//                                            {
//                                                suStr = returnData["Result"]["ResponseStatus"]["SuccessEntitys"].ToStringV1();
//                                                array = JsonConvert.DeserializeObject<JArray>(suStr);
//                                                List<string> lxrNos = array.Select(x => x["Number"].ToStringV1()).Where(x=>!x.IsNullOrEmptyOrWhiteSpace()).ToList();
//                                                if (lxrNos.Count>0)
//                                                {
//                                                    Root = new JObject();
//                                                    JObject Model = new JObject();
//                                                    Model["FID"] = custId;
//                                                    JArray xlrArray = new JArray();
//                                                    foreach (var xlrNo in lxrNos)
//                                                    {
//                                                        JObject xlrObj = new JObject();

//                                                        JObject FContactId = new JObject();
//                                                        FContactId["FNumber"] = xlrNo;
//                                                        xlrObj["FContactId"] = FContactId;

//                                                        xlrObj["FIsDefaultConsigneeCT"] = false;
//                                                        xlrObj["FIsCopy"] = false;
//                                                        xlrArray.Add(xlrObj);
//                                                    }
//                                                    Model["FT_BD_CUSTLOCATION"] = xlrArray;
//                                                    Root["Model"] = Model;
//                                                    json = Root.ToStringV1();
//                                                    msg = string.Empty;
//                                                    isok = K3HelperV1.Save(ctx, formId, json, ref msg);
//                                                    if (!isok)
//                                                        isok = K3HelperV1.Draft(ctx, formId, json, ref msg);
//                                                    if (isok)
//                                                        LogHelper.XiaoManLog($"【客户保存联系人成功】【客户名称：{uObj.Name}】\n【json:{json}】", logType);
//                                                    else
//                                                        LogHelper.XiaoManLog($"【客户保存联系人失败】【客户名称：{uObj.Name}】\n【msg:{msg}】\n【json:{json}】", logType);
//                                                }
//                                            }
                                          
//                                        }
                                

//                                    }
                       
                       
//                                }
//                            }
//                            else
//                            {
//                                LogHelper.XiaoManLog($"【客户保存失败】【{uObj.Name}】\n【msg:{msg}】\n【json:{json}】", logType);
//                                continue;
//                            }
//                        }
                        
//                    }

//                }
//                catch (Exception ex)
//                {
//                    LogHelper.XiaoManLog($"【获取客户详细信息】【异常CDetail2002】\n【msg:{ex.Message}】", logType);
//                    continue;
//                }
               

//            }
//        }

       
//        public string FillContent(JObject dataObj,CustUpdateData uObj)
//        {
//            JArray companyArray = JsonConvert.DeserializeObject<JArray>(dataObj["company"].ToStringV1());

//            JObject Root = new JObject();
//            JObject Model = new JObject();
//            Model["FID"] = 0;
//            Model["FIsTrade"] = true;
//            //小满客户Id
//            Model["F_RLKX_xmcustid1"] = uObj.Id;
//            //客户编号
//            Model["FNumber "] = uObj.SerId;
//            //客户名称
//            Model["FName"] = uObj.Name;
//            //客户简称
//            Model["FShortName"] = uObj.ShortName; 
//            //创建组织
//            JObject FCreateOrgId = new JObject();
//            FCreateOrgId["FNumber"] = "100";
//            Model["FCreateOrgId"] = FCreateOrgId;
//            //使用组织
//            JObject FUseOrgId = new JObject();
//            FUseOrgId["FNumber"] = "100";
//            Model["FUseOrgId"] = FUseOrgId;
//            //州
//            JObject F_RLKX_continent = new JObject();
//            F_RLKX_continent["FNumber"] = "";
//            Model["F_RLKX_continent"] = F_RLKX_continent;

//            //国家
//            string country = "country".GetValueByKey(companyArray, "2");
//            if (!country.IsNullOrEmptyOrWhiteSpace())
//            {
//                string countryNumber = auxiliaryList.Where(x => x.TypeName.EqualsV1("国家") && x.Name.EqualsV1(country)).Select(x=>x.Number).FirstOrDefault().ToStringV1();
//                JObject FCOUNTRY = new JObject();
//                FCOUNTRY["FNumber"] = countryNumber;
//                Model["FCOUNTRY"] = FCOUNTRY;
//            }

//            //地区
//            JObject FPROVINCIAL = new JObject();
//            FPROVINCIAL["FNumber"] = "";
//            Model["FPROVINCIAL"] = FPROVINCIAL;
//            //地址
//            string address = "address".GetValueByKey(companyArray, "4");
//            Model["FADDRESS"] = address;
//            //销售员
//            string saler= "28514799207966".GetValueByKey(companyArray, "5");
//            if (!saler.IsNullOrEmptyOrWhiteSpace())
//            {
//                var salerObj = salerList.Where(x => x.Name.EqualsV1(saler)).FirstOrDefault();
//                if (salerObj!=null)
//                {
//                    //部门
//                    JObject FSALDEPTID = new JObject();
//                    FSALDEPTID["FNumber"] = salerObj.dptNumebr;
//                    Model["FSALDEPTID"] = FSALDEPTID;
//                    //销售员
//                    JObject FSELLER = new JObject();
//                    FSELLER["FNumber"] = salerObj.Number;
//                    Model["FSELLER"] = FSELLER;
//                }     
//            }
//            Model["FISCREDITCHECK"] = true;

//            //客户类别
//            string custType = "32483931076905".GetValueByKey(companyArray, "5");
//            string custTypeNumber = auxiliaryList.Where(x => x.TypeName.EqualsV1("国家") && x.Name.EqualsV1(country)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//            JObject FCustTypeId = new JObject();
//            FCustTypeId["FNumber"] = custTypeNumber;
//            Model["FCustTypeId"] = FCustTypeId;

//            //客户分组
//            //string custGroup = "32483931076905".GetValueByKey(companyArray, "5");
//            //string custGroupNumber= custGroupList.Where(x => x.Name.EqualsV1(custGroup)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//            //JObject FGroup = new JObject();
//            //FGroup["FNumber"] = custGroupNumber;
//            //Model["FGroup"] = FGroup;

//            //公司规模
//            string companyScale = "32485585051114".GetValueByKey(companyArray, "5");
//            string companyScaleNumber = auxiliaryList.Where(x => x.TypeName.EqualsV1("公司规模") && x.Name.EqualsV1(companyScale)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//            JObject FCompanyScale = new JObject();
//            FCompanyScale["FNumber"] = companyScaleNumber;
//            Model["FCompanyScale"] = FCompanyScale;

//            //公司类别
//            string companyClassify = "32484180567865".GetValueByKey(companyArray, "5");
//            string companyClassifyNumber = auxiliaryList.Where(x => x.TypeName.EqualsV1("公司类别") && x.Name.EqualsV1(companyClassify)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//            JObject FCompanyClassify = new JObject();
//            FCompanyClassify["FNumber"] = companyClassifyNumber;
//            Model["FCompanyClassify"] = FCompanyClassify;

//            //公司性质
//            string companyNature = "32485517064215".GetValueByKey(companyArray, "5");
//            string companyNatureNumber = auxiliaryList.Where(x => x.TypeName.EqualsV1("公司性质") && x.Name.EqualsV1(companyNature)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//            JObject FCompanyNature = new JObject();
//            FCompanyNature["FNumber"] = companyNatureNumber;
//            Model["FCompanyNature"] = FCompanyNature;
//            //发票抬头
//            Model["FINVOICETITLE"] = uObj.Name;
//            //客户行业
//            string KHHY = "32485651749168".GetValueByKey(companyArray, "5");
//            string KHHYNumber = auxiliaryList.Where(x => x.TypeName.EqualsV1("客户行业") && x.Name.EqualsV1(KHHY)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//            JObject F_RLKX_KHHY = new JObject();
//            F_RLKX_KHHY["FNumber"] = KHHYNumber;
//            Model["F_RLKX_KHHY"] = F_RLKX_KHHY;

//            //业务员客户类别
//            string YWYKHLB = "32483807464280".GetValueByKey(companyArray, "5");
//            string YWYKHLBNumber = MJList.Where(x => x.TypeName.EqualsV1("业务员客户类别") && x.Name.EqualsV1(YWYKHLB)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//            Model["F_RLKX_YWYKHLB"] = YWYKHLBNumber;

//            //客户来源
//            string KHLY = "origin".GetValueByKey(companyArray, "1");
//            string KHLYNumber = custSourceList.Where(x=>x.Name.EqualsV1(KHLY)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//            JObject F_RLKX_KHLY = new JObject();
//            F_RLKX_KHLY["FNumber"] = KHLYNumber;
//            Model["F_RLKX_KHLY"] = F_RLKX_KHLY;

//            //处理商户信息 (子单据头)
//            {
//                JObject swxx = new JObject();
//                swxx["FEntryId"] = 0;
//                //省份 
//                string province = "province".GetValueByKey(companyArray, "2");
//                string provinceNumber = auxiliaryList.Where(x => x.TypeName.EqualsV1("省份") && x.Name.EqualsV1(province)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//                JObject FPROVINCE = new JObject();
//                FPROVINCE["FNumber"] = provinceNumber;
//                swxx["FPROVINCE"] = FPROVINCE;
//                //城市 
//                string city = "city".GetValueByKey(companyArray, "2");
//                string cityNumber = auxiliaryList.Where(x => x.TypeName.EqualsV1("市") && x.Name.EqualsV1(city)).Select(x => x.Number).FirstOrDefault().ToStringV1();
//                JObject FCITY = new JObject();
//                FCITY["FNumber"] = cityNumber;
//                swxx["FCITY"] = FCITY;

//                Model["FT_BD_CUSTOMEREXT"] = swxx;
//            }

//            Root["Model"] = Model;
//            string json = Root.ToStringV1();
//            return json;
//        }

//    }
//}
